package com.anbinh.doctor.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.anbinh.doctor.R;
import com.anbinh.doctor.model.ItemMeu;

public class MonthAdapter extends ArrayAdapter<ItemMeu> {
	private int resource;
	private LayoutInflater layoutInflater;
	private List<ItemMeu> listData;
	private int idCheked;
	private Context mContext;

	public MonthAdapter(Context mContext, int resource, List<ItemMeu> models,
			int idChecked) {
		super(mContext, resource, models);
		this.resource = resource;
		this.listData = models;
		layoutInflater = LayoutInflater.from(mContext);
		this.idCheked = idChecked;
		this.mContext = mContext;
	}

	public class ViewHolder {
		public TextView lblTitle;
		public ImageView icon;

	}

	@Override
	public ItemMeu getItem(int position) {
		return listData.get(position);
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = layoutInflater.inflate(resource, null, true);

			viewHolder.lblTitle = (TextView) convertView
					.findViewById(R.id.lblChuyenKhoaName);

			//viewHolder.icon = (ImageView) convertView.findViewById(R.id.icon);

			convertView.setTag(viewHolder);

		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		ItemMeu item = getItem(position);

		viewHolder.lblTitle.setText(String.format(mContext.getResources().getString(R.string.thang), item.getTitle()));
		//viewHolder.icon.setImageResource(item.getIcon());

		return convertView;
	}
}
